package com.dragon.modules.yuegou.model.wallet;

import com.dragon.modules.yuegou.entity.wallet.MemberCardEntity;
import com.dragon.modules.yuegou.enums.CardForm;
import com.dragon.modules.yuegou.enums.CardType;
import com.dragon.modules.yuegou.enums.wallet.MemberCardBindStatus;
import com.dragon.modules.yuegou.enums.wallet.MemberCardPresentStatus;
import com.dragon.modules.yuegou.enums.wallet.MemberCardSource;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 会员悦卡（简称悦卡）模型类
 * 
 * @author pbuilder generated
 * @date 2019-03-05 11:27:23
 * @company sgy
 * @version 2.0
 * @see Length 长度限制
 * @see NotNull 对象非空
 * @see NotEmpty 字符串、集合、表、数组非空
 */
public class MemberCard extends MemberCardEntity{

	private CardTemplate cardTemplate;

	@ApiModelProperty("折扣")
	private BigDecimal discountRate;

	@ApiModelProperty("当天已使用金额")
	private BigDecimal useAmount;

	@ApiModelProperty("状态 0-已使用,1-已过期,2-赠送中,3-已退款")
	private String status;

	@ApiModelProperty("状态 0-已使用,1-已过期,2-赠送中,3-已退款")
	private String statusName;
	
	@ApiModelProperty("悦卡图片地址")
	private String imgUrl;
	
	@ApiModelProperty("悦卡名称")
	private String cardName;
	
	@ApiModelProperty("可用商圈")
	private List<String> busdNames;

	@ApiModelProperty("购买金额")
	private BigDecimal payFee;

	@ApiModelProperty("订单号")
	private String orderNo;

	@ApiModelProperty("赠送张数")
	private Integer sendNum;

	@ApiModelProperty("领取张数")
	private Integer receiveNum;

	@ApiModelProperty("是否可赠送")
	private Boolean isPresent;

	@ApiModelProperty("赠送类型 0-赠送给好友、1-生成提取码")
	private Integer presentType;

	@ApiModelProperty("提取码code，多个用逗号隔开")
	private String extractCodes;

	@ApiModelProperty("赠送id")
	private String presentId;
	
	@ApiModelProperty("会员电话")
	private String mobile;
	
	@ApiModelProperty("会员昵称")
	private String memberName;
	
	@ApiModelProperty("企业昵称")
	private String companyName;
	
	@ApiModelProperty("悦卡类型 0-福利卡-WELFARE_CARD、1-预付卡-PREPAY_CARD")
	private CardType cardType;

	@ApiModelProperty("卡密码")
	private String cardPwd;

	@ApiModelProperty("悦卡类型")
	private String cardTypeName;

	@ApiModelProperty("悦卡形式 悦卡形式 0-虚拟卡 1-实体卡")
	private CardForm cardForm;

	@ApiModelProperty("悦卡形式")
	private String cardFormName;

	@ApiModelProperty("悦卡应用场景")
	private String scenarioType;

	public String getScenarioType() {
		return scenarioType;
	}

	public void setScenarioType(String scenarioType) {
		this.scenarioType = scenarioType;
	}

	public Boolean getIsPresent() {
		return isPresent;
	}

	public void setIsPresent(Boolean isPresent) {
		this.isPresent = isPresent;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getMemberName() {
		return memberName;
	}

	public void setMemberName(String memberName) {
		this.memberName = memberName;
	}

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	public CardType getCardType() {
		return cardType;
	}

	public void setCardType(CardType cardType) {
		this.cardType = cardType;
	}

	public Integer getSendNum() {
		return sendNum;
	}

	public void setSendNum(Integer sendNum) {
		this.sendNum = sendNum;
	}
	public Integer getReceiveNum() {
		return receiveNum;
	}

	public void setReceiveNum(Integer receiveNum) {
		this.receiveNum = receiveNum;
	}
	public Integer getPresentType() {
		return presentType;
	}

	public void setPresentType(Integer presentType) {
		this.presentType = presentType;
	}

	public String getExtractCodes() {
		return extractCodes;
	}

	public void setExtractCodes(String extractCodes) {
		this.extractCodes = extractCodes;
	}

	public String getPresentId() {
		return presentId;
	}

	public void setPresentId(String presentId) {
		this.presentId = presentId;
	}

	public String getCardTypeName() {
		return cardTypeName;
	}

	public void setCardTypeName(String cardTypeName) {
		this.cardTypeName = cardTypeName;
	}

	public CardForm getCardForm() {
		return cardForm;
	}

	public void setCardForm(CardForm cardForm) {
		this.cardForm = cardForm;
	}

	public String getCardFormName() {
		return cardFormName;
	}

	public void setCardFormName(String cardFormName) {
		this.cardFormName = cardFormName;
	}

	/**
	 * 构造一个空会员悦卡（简称悦卡）模型对象
	 */
	public MemberCard(){
		super();
	}
	
	/**
	 * 依据实体对象的信息构造一个会员悦卡（简称悦卡）模型对象
	 * 
	 * @param entity 实体对象
	 */
	public MemberCard(MemberCardEntity entity){
		super(entity);
	}

	/**
	 * 依据其它对象的信息构造一个会员悦卡（简称悦卡）模型对象
	 * 
	 * @param other 其它对象
	 */
	public MemberCard(MemberCard other){
		super(other);
	}

	public CardTemplate getCardTemplate() {
		return cardTemplate;
	}

	public void setCardTemplate(CardTemplate cardTemplate) {
		this.cardTemplate = cardTemplate;
	}
	
	public String getCardName() {
		return cardName;
	}

	public void setCardName(String cardName) {
		this.cardName = cardName;
	}

	public String getImgUrl() {
		return imgUrl;
	}

	public void setImgUrl(String imgUrl) {
		this.imgUrl = imgUrl;
	}
	
	public List<String> getBusdNames() {
		return busdNames;
	}

	public void setBusdNames(List<String> busdNames) {
		this.busdNames = busdNames;
	}

	public String getStatus() {
		if (getRemain().compareTo(BigDecimal.ZERO)==0){
			return "0";
		}else if (super.getRefund()){
			return "3";
		}else if (getRemain().compareTo(BigDecimal.ZERO) > 0
				&& getEndTime()!=null && getEndTime().compareTo(LocalDateTime.now()) <= 0){
			return "1";
		}else if (getPresentStatus()!=null && getEndTime()!=null
				&& getPresentStatus().getCode().toString().equals(MemberCardPresentStatus.PRESENTING.getCode().toString())
				&& getEndTime().compareTo(LocalDateTime.now()) >0){
			return "2";
		}else if (getRemain().compareTo(BigDecimal.ZERO) > 0
				&& getEndTime()!=null && getEndTime().compareTo(LocalDateTime.now()) > 0){
			return "4";
		}
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getStatusName() {
		if ("0".equals(getStatus())){
			return "已使用";
		}
		if ("1".equals(getStatus())){
			return "已过期";
		}
		if ("2".equals(getStatus())){
			return "赠送中";
		}
		if ("3".equals(getStatus())){
			return "已退卡";
		}
		if ("4".equals(getStatus())){
			return "正常使用";
		}
		return statusName;
	}

	public void setStatusName(String statusName) {
		this.statusName = statusName;
	}

	@Override
	public String getId() {
    	return id;
    }

    /**
	 * 设置会员悦卡ID
	 * 
	 * @param id 会员悦卡ID
	 * @return 当前对象
	 */
    public MemberCard id(String id) {
    	this.id = id;
    	return this;
    }

	@Override
	public String getMemberId() {
    	return memberId;
    }

    /**
	 * 设置会员ID（冗余ID）
	 * 
	 * @param memberId 会员ID（冗余ID）
	 * @return 当前对象
	 */
    public MemberCard memberId(String memberId) {
    	this.memberId = memberId;
    	return this;
    }

	@Override
	public String getMemberWalletId() {
    	return memberWalletId;
    }

    /**
	 * 设置会员钱包ID
	 * 
	 * @param memberWalletId 会员钱包ID
	 * @return 当前对象
	 */
    public MemberCard memberWalletId(String memberWalletId) {
    	this.memberWalletId = memberWalletId;
    	return this;
    }

	@Override
	public String getCardTemplateId() {
    	return cardTemplateId;
    }

    /**
	 * 设置悦卡类型ID
	 * 
	 * @param cardTemplateId 悦卡类型ID
	 * @return 当前对象
	 */
    public MemberCard cardTemplateId(String cardTemplateId) {
    	this.cardTemplateId = cardTemplateId;
    	return this;
    }

	public BigDecimal getPayFee() {
		return payFee;
	}

	public void setPayFee(BigDecimal payFee) {
		this.payFee = payFee;
	}

	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	@Override
	public String getCardNo() {
    	return cardNo;
    }



    /**
	 * 设置悦卡卡号
	 * 
	 * @param cardNo 悦卡卡号
	 * @return 当前对象
	 */
    public MemberCard cardNo(String cardNo) {
    	this.cardNo = cardNo;
    	return this;
    }

	@Override
	public String getCompanyId() {
    	return companyId;
    }

    /**
	 * 设置企业ID（发放悦卡的企业，会员自行购买时此字段为空）
	 * 
	 * @param companyId 企业ID（发放悦卡的企业，会员自行购买时此字段为空）
	 * @return 当前对象
	 */
    public MemberCard companyId(String companyId) {
    	this.companyId = companyId;
    	return this;
    }

	@Override
	public String getEmployeesId() {
    	return employeesId;
    }

    /**
	 * 设置员工id
	 * 
	 * @param employeesId 员工id
	 * @return 当前对象
	 */
    public MemberCard employeesId(String employeesId) {
    	this.employeesId = employeesId;
    	return this;
    }

	@Override
	public BigDecimal getRemain() {
    	return remain;
    }

    /**
	 * 设置悦卡余额
	 * 
	 * @param remain 悦卡余额
	 * @return 当前对象
	 */
    public MemberCard remain(BigDecimal remain) {
    	this.remain = remain;
    	return this;
    }

	@Override
	public BigDecimal getAmount() {
    	return amount;
    }

    /**
	 * 设置悦卡总额（不变）
	 * 
	 * @param amount 悦卡总额（不变）
	 * @return 当前对象
	 */
    public MemberCard amount(BigDecimal amount) {
    	this.amount = amount;
    	return this;
    }

	@Override
	public Integer getVersion() {
    	return version;
    }

    /**
	 * 设置版本
	 * 
	 * @param version 版本
	 * @return 当前对象
	 */
    public MemberCard version(Integer version) {
    	this.version = version;
    	return this;
    }

	@Override
	public MemberCardSource getSource() {
    	return source;
    }

    /**
	 * 设置[枚举]悦卡来源：0-会员充值-MEMBER_BUY、1-企业发放-COMPANY_GRANT、2-实体卡绑定-ENTITY_BIND
	 * 
	 * @param source [枚举]悦卡来源：0-会员充值-MEMBER_BUY、1-企业发放-COMPANY_GRANT、2-实体卡绑定-ENTITY_BIND
	 * @return 当前对象
	 */
    public MemberCard source(MemberCardSource source) {
    	this.source = source;
    	return this;
    }

	@Override
	public LocalDateTime getStartTime() {
    	return startTime;
    }

    /**
	 * 设置有效期开始时间（包含）
	 * 
	 * @param startTime 有效期开始时间（包含）
	 * @return 当前对象
	 */
    public MemberCard startTime(LocalDateTime startTime) {
    	this.startTime = startTime;
    	return this;
    }

	@Override
	public LocalDateTime getEndTime() {
    	return endTime;
    }

    /**
	 * 设置有效期截止时间（不包含）
	 * 
	 * @param endTime 有效期截止时间（不包含）
	 * @return 当前对象
	 */
    public MemberCard endTime(LocalDateTime endTime) {
    	this.endTime = endTime;
    	return this;
    }

	@Override
	public Boolean getRefund() {
    	return refund;
    }

    /**
	 * 设置是否已退卡
	 * 
	 * @param refund 是否已退卡
	 * @return 当前对象
	 */
    public MemberCard refund(Boolean refund) {
    	this.refund = refund;
    	return this;
    }

	@Override
	public MemberCardBindStatus getBindStatus() {
    	return bindStatus;
    }

    /**
	 * 设置[枚举]绑定状态：0-不能绑定-NOT_CAN、1-已绑定-BINDING、2-已解绑-UNBINDING
	 *
	 * @param bindStatus [枚举]绑定状态：0-不能绑定-NOT_CAN、1-已绑定-BINDING、2-已解绑-UNBINDING
	 * @return 当前对象
	 */
    public MemberCard bindStatus(MemberCardBindStatus bindStatus) {
    	this.bindStatus = bindStatus;
    	return this;
    }

	@Override
	public MemberCardPresentStatus getPresentStatus() {
    	return presentStatus;
    }

    /**
	 * 设置[枚举]赠送状态：0-未赠送-NOT_PRESENT、1-赠送中-PRESENTING、2-已赠送-PRESENTED
	 * 
	 * @param presentStatus [枚举]赠送状态：0-未赠送-NOT_PRESENT、1-赠送中-PRESENTING、2-已赠送-PRESENTED
	 * @return 当前对象
	 */
    public MemberCard presentStatus(MemberCardPresentStatus presentStatus) {
    	this.presentStatus = presentStatus;
    	return this;
    }

	@Override
	public Boolean getPrioritization() {
    	return prioritization;
    }

    /**
	 * 设置是否优先排序 0 不优先 1优先
	 * 
	 * @param prioritization 是否优先排序 0 不优先 1优先
	 * @return 当前对象
	 */
    public MemberCard prioritization(Boolean prioritization) {
    	this.prioritization = prioritization;
    	return this;
    }

	@Override
	public LocalDateTime getCreatedTime() {
    	return createdTime;
    }

    /**
	 * 设置创建时间
	 * 
	 * @param createdTime 创建时间
	 * @return 当前对象
	 */
    public MemberCard createdTime(LocalDateTime createdTime) {
    	this.createdTime = createdTime;
    	return this;
    }

	@Override
	public LocalDateTime getModifiedTime() {
    	return modifiedTime;
    }

    /**
	 * 设置
	 * 
	 * @param modifiedTime 
	 * @return 当前对象
	 */
    public MemberCard modifiedTime(LocalDateTime modifiedTime) {
    	this.modifiedTime = modifiedTime;
    	return this;
    }


	public BigDecimal getDiscountRate() {
		return discountRate;
	}

	public void setDiscountRate(BigDecimal discountRate) {
		this.discountRate = discountRate;
	}



	public BigDecimal getUseAmount() {
		return useAmount;
	}

	public void setUseAmount(BigDecimal useAmount) {
		this.useAmount = useAmount;
	}

	public String getCardPwd() {
		return cardPwd;
	}

	public void setCardPwd(String cardPwd) {
		this.cardPwd = cardPwd;
	}
}
